<?php
/**
/*Receives array from $_POST and parses the tag information string, delimited by "|"
*/
$connectstatus = mysql_connect("vrbsky1.cs.ua.edu", "areeves", "");
if (!$connectstatus){
	die('Couldn\'t connect: ' . mysql_error ());
	}
mysql_select_db("areeves_db") or die("cannot select database");
$tags = $_POST;
$flag = 0;
foreach ($tags as $value){
	$value = explode("|", $value);
	$attr = "";
	for ($i=6; $i<count($value); $i++){
		$attr = $attr . $value[$i] . "|";
	}
	//text|text|text|int|int|text|text|text
	$sql_attempt="INSERT INTO `Tags` (`Type`, `Title`, `Description`, `Latitude`, `Longitude`, `Date`, `Attributes`) VALUES ('$value[0]','$value[1]','$value[2]','$value[3]','$value[4]', '$value[5]', '$attr')";
	if(!mysql_query($sql_attempt, $connectstatus)){
		$flag = 1;
		die('Error: '. mysql_error());
	}
}
if($flag !== 1){
	echo "Success";
}

mysql_close($connectstatus);
//var_dump($tags);
?>